{% extends "base.html" %}
{% block title %} Flags | sh00t{% endblock %}

{% block page %}
<ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="/">Dashboard</a></li>
    <li class="breadcrumb-item"><a href="/app/flags/all">All Flags</a></li>
    <li class="breadcrumb-item"><a href="/app/flags/open">Open Flags</a></li>
    <li class="breadcrumb-item active"> <i class="fa fa-flag"></i> Flag</li>
</ol>
<div class="row">
    <div class="col-lg-5">
        {% if not assessments_list %}
            <br /><p>No Assessments found. A flag must be associated with an assessment. <a href="/app/assessments/new/">Create an assessment</a> before creating a flag.</p>
        {% else %}
            <form role="form" method="post">
                {% if "success" == submitted %}
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="alert alert-info alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <i class="fa fa-info-circle"></i> Submitted
                            </div>
                        </div>
                    </div>
                {% endif %}
                <div class="form-group">
                    <label>Title</label>
                    <input class="form-control" name="title" autocomplete="off" />
                </div>
                <div class="form-group">
                    <label>Note</label>
                    <textarea class="form-control" rows="15" name="note"></textarea>
                </div>
                <div class="form-group">
                    <label for="assessment">Assessment</label>
                    <select id="assessment" class="form-control" name="assessment">
                        {% for assessment in assessments_list %}
                            <option value="{{ assessment.id }}">{{ assessment.name }}</option>
                        {% endfor %}
                    </select>
                </div>
                <button type="submit" class="btn btn-primary">Submit</button>
                {% csrf_token %}
            </form>
        {% endif %}
    </div>
    <div class="col-lg-7">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title"><i class="fa fa-flag"></i> Open Flags</h4>
            </div>
            <div class="panel-body">
                {% if recent_flags %}
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover table-striped">
                            <thead>
                                <tr>
                                    <th>Title</th>
                                    <th>Project</th>
                                    <th>Assessment</th>
                                    <th>Added</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for flag in recent_flags %}
                                    <tr>
                                        <td><a href="/app/flag/{{ flag.id }}/">{{ flag.title }}</a></td>
                                        <td><a href="/app/project/{{ flag.assessment.project.id}}/">{{ flag.assessment.project.name }}</a></td>
                                        <td><a href="/app/assessment/{{ flag.assessment.id}}/">{{ flag.assessment.name }}</a></td>
                                        <td>{{ flag.added }}</td>
                                    </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                    <div class="text-right">
                        <a href="/app/flags/open/?sort=-added">View all open flags <i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                {% else %}
                    <h4><i class="fa fa-arrow-left"></i> Add a flag</h4>
                {% endif %}
            </div>
        </div>
    </div>
</div>
{% endblock %}
